
import java.util.ArrayList;

public class RepositoryJPG implements IRepositoryAbstract
{
    private String type = "jpg";
    private static ArrayList<String> url_img_list = new ArrayList<String>();
    private static ArrayList<String> url_list = new ArrayList<String>();
    Grabber grabber = new Grabber();
    public String getContent(String url_address)
    {
        return grabber.getContentHTMLFile(url_address);
    }
    public void initUrlLinks(String start_page)
    {
        url_list.addAll(grabber.getTextUrlLinks(start_page, start_page));
        addUrlLinks(start_page);
    }
    public void addUrlLinks(String start_page)
    {            
        while(url_img_list.isEmpty())
        {
            String url_address = (String)url_list.get(0);
            url_list.remove(0);
            url_img_list.addAll(grabber.getImgUrlLinks(url_address, type));
            if(url_list.size() < 5)
            {
                url_list.addAll(grabber.getTextUrlLinks(start_page, url_address));
            }
        }
    }
    public ArrayList<String> getUrlLinks()
    {
        return url_img_list;
    }
    public String getType()
    {
        return type;
    }
}
